#coding:utf-8
from django.db import models

# Create your models here.
#定义主机
class Host(models.Model):
    ip = models.GenericIPAddressField()
    port = models.IntegerField(default=2222)

    def __unicode__(self):
        return "{0} {1}".format(self.ip,self.port)
#域名信息
class Domain(models.Model):
    domain = models.CharField(max_length=200)

    def __unicode__(self):
        return "{0}".format(self.domain)
#服务
class Server(models.Model):
    name = models.CharField(max_length=200)

    def __unicode__(self):
        return "{0}".format(self.name)
#版本信息
class Version(models.Model):
    code = models.IntegerField()

#具体的APP
class WebServer(models.Model):
    server = models.ForeignKey("Server")
    host = models.ForeignKey("Host")
    domain = models.ForeignKey("Domain")
    version = models.ForeignKey("Version")
    url = models.URLField(null=True,blank=True)
    path = models.FilePathField(null=True,blank=True)
    def __unicode__(self):
        return "{0} {1} {2}".format(self.host.ip,self.server.name,self.domain.domain)
